/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.polytec.controller;

import com.polytec.beans.CategorieFacade;
import com.polytec.beans.CompteFacade;
import com.polytec.controller.util.JsfUtil;
import com.polytec.entities.Categorie;
import com.polytec.entities.Compte;
import java.io.Serializable;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

/**
 *
 * @author Lahmadi
 */
@ManagedBean
@SessionScoped
public class RechercheController implements Serializable {

    /**
     * Creates a new instance of LoginController
     */
    public RechercheController() {
    }
    @EJB
    private CategorieFacade categorieFacade;
    private String categorieName;
  

    
    public String getCategorieName() {
        return categorieName;
    }

    public void setCategorieName(String categorieName) {
        this.categorieName = categorieName;
    }

   

    public String Search() {
        Categorie categorie = categorieFacade.findByCategorieName(categorieName);
        if (categorie == null) {
            //System.err.println("username not found");
            JsfUtil.addErrorMessage("category name not found");

            return null;
        } else {
         return "index.xhtml?faces-redirect=true";
    }
}
}
